package edu.ccut.saturn.studio.wfg.xml.loader;

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import edu.ccut.saturn.studio.wfg.model.Shape;
import edu.ccut.saturn.studio.wfg.wfgmodel.SaturnName;
import edu.ccut.saturn.studio.wfg.wfgmodel.SaturnSubActivityNode;

public class SaturnSubActivityNodeLoader extends NodeLoader {

	@Override
	public List<Shape> loadNodes(Element root) {
		NodeList subNodes = root.getElementsByTagName(SaturnName.XML_NAME);
		List<Shape> subLists = new ArrayList<Shape>();
		for(int i = 0 ; i<subNodes.getLength();i++){
			Node auto = subNodes.item(i);
			if(SaturnName.KEY_NODE_ATTRIBUTE_SUB.equals(super.getNodeAttributeValue(auto, SaturnName.XML_TYPE))){
				SaturnSubActivityNode subNode = new SaturnSubActivityNode();
				// 基本信息
				subNode.setDescription(super.getNodeElementValue(auto, Shape.KEY_NODE_DESCRIPTION));
				subNode.setId(super.getNodeAttributeValue(auto, Shape.KEY_ATTRIBUTE_ID));
				subNode.setLocation(super.getLocation(auto));
				subNode.setName(super.getNodeElementValue(auto, Shape.KEY_NODE_NAME));
				subNode.setNextId(super.getNodeAttributeValue(auto, Shape.KEY_ATTRIBUTE_SHAPE_NEXT_ID));
				subNode.setPolymeMode(super.getNodeElementValue(auto, SaturnName.KEY_NODE_ELEMENT_POLYMEMODE));
				subNode.setSubProcess(super.getNodeElementValue(auto, SaturnName.KEY_NODE_ELEMENT_SUBPROCESS));
				subNode.setSize(super.getSize());
				// 触发信息
				subNode.setFormDataAttributeList(super.getSaturnAttributeList(auto, SaturnName.KEY_NODE_ELEMENT_FORMDATA, SaturnName.KEY_NODE_NAME_DATA,SaturnName.METHOD_GETSATURNATTRIB));
				subLists.add(subNode);
			}
		}
		return subLists;
	}

}
